/*
 * @Author: mikey.zhaopeng 
 * @Date: 2018-04-26 14:58:21 
 * @Last Modified by: mikey.zhaopeng
 * @Last Modified time: 2018-05-19 15:29:55
 */

import Vue from 'vue'
// import myHeader from '../../components/Header';
// import myFooter from '../../components/Footer';
export default {

  components: {
    // myFooter
  },
  data() {
    return {
      checkedMsg: 0,
      username: "",
      password: "",
    }
  },
  mounted: function () {
    // this.creatCode();
  },
  methods: {

    //登录并检查输入信息
    save: function () {
        let that=this;
        that.axios.post('cp/v1/User/login', {
        username: that.username,
        password: that.password,
      }).then(res => {
        if (res.data.code == 200) {
          if (that.username == res.data.data.name && that.password == res.data.data.password) {
            localStorage.userInfo = JSON.stringify(res.data.data);
            that.$message({
              showClose: false,
              message: '登录成功',
              type: 'success',
              center: false
            })
            that.$router.push({
              path: '/home'
            })
          } else {
            that.$message({
              showClose: true,
              message: '账号密码不匹配',
              type: 'error',
              center: true
            });
          }
        }else{
            that.$message({
                showClose: true,
                message: '网络异常或账号密码不匹配',
                type: 'error',
                center: true
              });
        }

      })
    },

    goregistered: function () {
      this.$router.push({
        path: 'activity'
      })
    }
  },
}
